<?php
require_once('lock.php');
require_once('access_adm.php');
require_once('../php/includes/constants.php');
require_once('../php/includes/db_access.php');
require_once('include_adm.php');
include('../php/includes/imagehandler.php');

$db = new Db(SERVER, USERNAME, PASSWORD);


if (isset($_POST['actType']) && ($_POST['actType'] == 'opslaan')) {


    $aValues['naam'] = stripslashes($_POST['name']);
    $aValues['eind_datum'] = $_POST['Einddatum'];
    $aValues['aktief'] = $_POST['aktief'];



    $banner_id = $db->Insert('aktie_banner', $aValues, '', true);

    // BEGIN upload image

    $uploadedfile = $_FILES['file']['tmp_name'];

    list($width, $height) = getimagesize($uploadedfile);

    if ($width == 352 && $height == 97) {

        $destination = '../gfx/banner/';
        $filename = $_FILES["file"]["name"];
        copy($uploadedfile, $destination . $filename);


        $sql_insert2 = mysql_query("UPDATE aktie_banner SET img_b='$filename'  where aktie_id=" . $banner_id);

        if ($sql_insert2) {
            header('Location: redactioneel_list.php');
        } else {
            header('Location: aktiebanner_add.php');
        }
    } else {
        echo "<font color='red'>De banner moet op maat van 352px / 97px </font>";
    }
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
        <link rel="shortcut icon" href="images/favicon.ico" type="image/x-icon" />
        <link rel="stylesheet" href="styles/beheer.css" type="text/css" charset="utf-8" media="screen">
            <link rel="stylesheet" href="styles/jquery-ui-1.8.18.custom.css" type="text/css" charset="utf-8" media="screen">


                <META NAME="ROBOTS" CONTENT="NOARCHIVE, NOINDEX, NOFOLLOW">
                    <META NAME="GOOGLEBOT" CONTENT="NOSNIPPET"> 
                        <script type="text/javascript" src="js/jquery-1.4.3.min.js"></script>
                        <script type="text/javascript" src="js/jquery-1.7.1.js"></script>
                        <script type="text/javascript" src="js/jquery.curvycorners.packed.js"></script>
                        <script type="text/javascript" src="js/radius.js"></script>
                        <script type="text/javascript" src="js/fout.js"></script>
                        <script type="text/javascript" src="js/foutbgone.js"></script>
                        <script type="text/javascript" src="js/jquery.ui.core.js"></script>
                        <script type="text/javascript" src="js/jquery.ui.widget.js"></script>
                        <script type="text/javascript" src="js/jquery.ui.datepicker.js"></script>

                        <script type="text/javascript" src="../tinymce/jscripts/tiny_mce/tiny_mce.js"></script>
                        <SCRIPT type="text/javascript">
                            <!--

                            function checkForm(f) {
                                var re = new RegExp("^[0-9a-z]([-_.]?[0-9a-z_])*@[0-9a-z]([-.]?[0-9a-z])*\\.[a-z]{2,}$",'i');

                                if (f.titel.value == "") {
                                    alert( "Je hebt de naam nog niet ingevuld!" );
                                    document.getElementById("titel").style.backgroundColor="#708CA2";
                                    f.titel.focus();
                                    return false ;
                          
                            
                                    if (f.datepicker.value == "") {
                                        alert( "Je hebt de einddatum nog niet ingevuld!" );
                                        document.getElementById("datepicker").style.backgroundColor="#708CA2";
                                        f.datepicker.focus();
                                        return false ;
                                    }
                                }
  



                                return true;
                            }

                            ////jquery datepicker met aangepast datumformaat
  
                            $(function() {
                                $('input#datepicker').datepicker({
                                    dateFormat: 'yy-mm-dd',
                                    changeMonth: false,
                                    changeYear: false
                                },
                                $.datepicker.regional['nl']);
                            });
                            //-->
                        </SCRIPT>
                        <!-- /TinyMCE -->
                        <title>CMS | Hollandsche meesters</title>
                        </head>

                        <body>

                            <div id="wrapper">
                                <div id="container">

<?php include_once 'header.html'; ?>

                                    <div id="content">
                                        <div class="kop">
                                            <h1>SCHILDER TOEVOEGEN</h1>
                                        </div>
                                        <div id="content-box">
                                            <div class="col-964">
                                                <div class="overzicht-box-gr">
                                                    <h2 class="radiusTLTR">Details</h2>
                                                    <div class="box-964 radiusBLBR">

                                                        <p>&nbsp;</p>
                                                        <p>
                                                            <table width="800" border="0" cellspacing="0" cellpadding="0">
                                                                <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="sform" id="sform" enctype="multipart/form-data" onSubmit="return checkForm(this)">
                                                                    <input type="hidden" name="actType" value="opslaan">
                                                                        <tr>
                                                                            <td width="200" height="30" valign="top">Naam</td>
                                                                            <td valign="top">
                                                                                <input type="text" name="name" value="" class="inp" onblur="this.style.backgroundColor='#fff';" id="titel" />
                                                                            </td>
                                                                        </tr>
                                                                        <tr>
                                                                            <td width="200" height="30" valign="top">Aktief</td>
                                                                            <td valign="top">
                                                                                <input name="aktief" type="radio"  id="aktief" value="Y" /> Ja &nbsp;&nbsp;&nbsp;&nbsp;
                                                                                <input name="aktief" type="radio"  id="aktief" value="N" /> Nee
                                                                            </td>
                                                                        </tr>
                                                                        <tr>
                                                                            <td width="200" valign="top">Einddatum</td>
                                                                            <td align="left" valign="top">
                                                                                <input type="text" name="Einddatum" value=""  id="datepicker" onblur="this.style.backgroundColor='#fff';"  style="width:150px" /><br></br>
                                                                            </td>
                                                                        </tr>
                                                                        <tr>
                                                                            <td width="200" height="30" valign="top">Banner</td>
                                                                            <td align="left" valign="top">
                                                                                <input type="file" name="file" class="inp"  style="width:382px" id="prfoto" />
                                                                            </td>
                                                                        </tr>
                                                                        <tr>
                                                                            <td>&nbsp;</td>
                                                                            <td align="left"><input type="image" name="opslaan" src="images/btn-opslaan.gif" width="67" height="25" class="btn" alt="Opslaan" title="Opslaan" /></td>
                                                                        </tr>
                                                                </form>
                                                            </table>
                                                        </p>
                                                    </div>
                                                </div>
                                            </div>		
                                        </div>
                                    </div>

                                </div>
                            </div>

                        </body>
                        </html>